<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use yii\widgets\LinkPager;
use yii\base\Widget;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\ArticleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $models backend\controllers\ArticleController */
/* @var $pages backend\controllers\ArticleController */

$this->title = 'Article Models';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="article-model-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Article Model', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'title' => [
                'attribute' => 'title',
                'format' => 'raw',
                'value' => function($model){
                    return '<a href="' .Url::to(['article/view', 'id' => $model->id]).'">'.$model->title.'</a>';
                },
            ],
            'summary',
//             'content:ntext',
//             'label_img',
            'cat.cat_name',
            // 'user_id',
            'user_name',
            'is_valid' => [
                'attribute' => 'is_valid',
                'value' => function($model){
                    return ($model->is_valid == 1)?'发布':'未发布';
                },
                'filter' => ['0' => '未发布', '1' => '发布'],
             ],
            'created_at:datetime',
            // 'updated_at',

            ['class' => 'yii\grid\ActionColumn'],
        ],
                
    ]); ?>

</div>
